import { ElMessage } from "element-plus";

// 定义消息类型
type MessageType = 'success' | 'warning' | 'info' | 'error';

/**
 *
 * @param msg 提示的内容
 * @param type 提示的类型
 * @param className 自定义样式类名
 */
function showToast(msg: string, type: MessageType, className: string = '') {
  ElMessage({
    message: msg,
    type,
    customClass: className
  });
}

function success(msg: string) {
  showToast(msg, "success");
}
function warning(msg: string) {
  showToast(msg, "warning");
}
function info(msg: string) {
  showToast(msg, "info");
}
function error(msg: string, className?: string) {
  console.log(msg, className)
  showToast(msg, "error", className || '');
}

export { showToast, success, warning, info, error };
